<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1.计算出字符串中出现次数最多的字符是什么，出现了多少次？
        let str="asaccccccsdcsfsccccssaaaaaad";
        let obj=new Object();
        let arr=str.split("");
        arr.forEach(function(item){
            obj[item] = obj[item] ? obj[item]+=1 : 1;
        })
        let max="",maxindex=0;
        for(let key in obj){
            if(maxindex < obj[key]){
                maxindex=obj[key];
                max=key;
            }
        }
        console.log(`次数最多的是:${max},出现了${maxindex}次`);
    </script>
</body>
</html>